package com.content.management.exception;

import com.content.management.util.enums.ResultCode;
import lombok.Setter;

import static com.content.management.util.enums.ResultCode.SAVE_ERROR;


/**
 * @author xinghu
 * @version 1.0
 * @date 2020/3/2 11:15 下午
 */
@Setter
public class BusinessException extends RuntimeException implements BaseEnum<ResultCode> {

	private Integer code;
	private String desc;

	public BusinessException() {
		this.code = SAVE_ERROR.getCode();
		this.desc = SAVE_ERROR.getDesc();
	}

	public BusinessException(BaseEnum<?> resultCode) {
		this.code = resultCode.getCode();
		this.desc = resultCode.getDesc();
	}

	public BusinessException(String message) {
		super(message);
		this.code = SAVE_ERROR.getCode();
		this.desc = message;
	}

	public BusinessException(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	@Override
	public Integer getCode() {
		return this.code;
	}

	@Override
	public String getDesc() {
		return this.desc;
	}
}
